﻿using System;
using System.Configuration;
using System.Text;
using System.Web.UI;
using SouthernLand.Common;

namespace SouthernLand
{
    public partial class Error : Page
    {
        private string strRequest = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            strRequest = Request.QueryString["error"];
            lblThongTin.Text = strRequest;

            // goi email cho admin website
            var sendmail = new SendMail();
            sendmail.MailServer = ConfigurationManager.AppSettings["SmtpServer"];
            sendmail.MailFrom = ConfigurationManager.AppSettings["EmailFrom"];
            sendmail.MailTo = ConfigurationManager.AppSettings["EmailWebmaster"];
            sendmail.Subject = "Co loi xay ra tu website: " +
                               ConfigurationManager.AppSettings["Domain"];

            // noi dung can goi
            var strBody = new StringBuilder(string.Empty);
            strBody.AppendLine("<br>");
            strBody.Append("<br> Thong tin loi : " + Server.GetLastError());
            strBody.Append("<br><br> Url : " + Globals.GetStringFromQueryString("aspxerrorpath"));

            sendmail.Body = strBody.ToString();
            SendMail.Send(sendmail);
        }
    }
}